<template>
  <page-form :x-uri="uri" :x-tabs="tabs" :reset-btn-text="false" :custom-components="custom" :bind-rules="rules" />
</template>

<script>
import PageForm from '@public/template/page_form.vue';
import Attach from './components/attach.vue';
import Completion from './components/completion.vue';
import Dudition from './components/audition.vue';
export default {
  components: {
    PageForm
  },
  data() {
    return {
      uri: '/course/admin/video/' + this.$route.params.id + '/section/' + this.$route.params.sid + '/edit',
      tabs: [
        {
          title: '点播列表',
          uri: '/course/video/list',
          meta: {
            permission: 'course.video.default'
          }
        },
        {
          title: '课时列表',
          uri: '/course/video/' + this.$route.params.id + '/section',
          meta: {
            permission: 'course.video.default.section'
          }
        },
        {
          title: '编辑课时',
          uri: '/course/video/' + this.$route.params.id + '/section/' + this.$route.params.sid + '/edit',
          meta: {
            permission: 'course.video.default.section'
          }
        }
      ],
      rules: {
        audition: [
          {
            validator: (rule, value, callback) => {
              const reg = /^([1-9]?\d|100)$/;
              if (!reg.test(value)) {
                return callback(new Error('必须为0-100的整数'));
              }
              callback();
            },
            trigger: ['blur', 'change']
          }
        ]
      },
      custom: {
        course_data_id: Attach,
        completion_conditions: Completion,
        audition: Dudition
      }
    };
  }
};
</script>
